package abstractComponent;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import concreteComponents.Secuencial;

import ar.edu.unq.tpi.pconc.Channel;

abstract public class Fuente {

	static Map<String, Class<? extends Fuente>> map = new HashMap<String, Class<? extends Fuente>>();

	public static void main(String[] args) throws InstantiationException,
			IllegalAccessException {
		Set<Channel<Integer>> channels = new HashSet<Channel<Integer>>();
		map.put("Secuencial", Secuencial.class);
		Fuente instance = map.get(args[0]).newInstance();
		for (int n = 1;n < args.length;n++) {
			int i = Integer.parseInt(args[n]);
			channels.add(new Channel<Integer>(i));
		}
		while (true) {
//			int toSend = instance.accion();
			for (Channel<Integer> channel : channels) {
				channel.send(instance.accion());
			}
		}
	}

	public abstract int accion();
}
